package com.xiaoxu.privatechat.dao.admin;


import com.xiaoxu.privatechat.entity.admin.OperaterLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description 后台操作日志类数据库操作层
 * @author xiaoxu
 * @date 2023/2/13
 */
@Repository
public interface OperaterLogDao extends JpaRepository<OperaterLog, Long> {
	
	/**
	 * @description 根据id查找操作日志
	 * @param id 日志id
	 * @return OperaterLog
	 */
	@Query("select ol from OperaterLog ol where ol.id = :id")
	OperaterLog find(@Param("id")Long id);
	
	/**
	 * @description 获取最近的指定条数的操作日志
	 * @param size 数量
	 * @return List<OperaterLog>
	 */
	@Query(value="select * from pc_operater_log order by create_time desc limit 0,:size",nativeQuery=true)
	List<OperaterLog> findLastestLog(@Param("size")int size);
}
